package com.app.db.datasource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * db1 数据源切换
 * @author liuli
 */
public class M1DataBaseContextHolder {
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
    private static Logger log = LoggerFactory.getLogger(M1DataBaseContextHolder.class);
    /**切换主库*/
    public static void setMaster() {
        contextHolder.set(DataSourceConstant.DB_MASTER1);
    }
    /**切换从库*/
    public static void setSalve() {
        contextHolder.set(DataSourceConstant.DB_SLAVE1);
    }
    /**获取数据源*/
    public static String getDBKey() {
        return contextHolder.get();
    }
    /**清除数据源*/
    public static void clearDBKey() {
        contextHolder.remove();
    }

}
